/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * LimpiarOutliersGUI.java
 *
 * Created on 16/11/2010, 07:53:28 PM
 */

package GUI;

import Control.Controladora;
import java.util.Vector;
import javax.swing.JOptionPane;

/**
 *
 * @author Gema
 */
public class LimpiarOutliersGUI extends javax.swing.JFrame {
    int minimo;
    int maximo;
    String nombreTabla;
    Vector<String> vectorTodosAtributos;
    Vector<String> vectorAtributoSeleccionado;

    /** Creates new form LimpiarOutliersGUI */
    public LimpiarOutliersGUI(String nombreTabla2, Vector<String> vectorAtributo, Vector<String> atributoSeleccionado) {
        initComponents();
        setLocationRelativeTo(null);
        nombreTabla=nombreTabla2;
        vectorTodosAtributos= new Vector<String>();
        vectorTodosAtributos=vectorAtributo;

        vectorAtributoSeleccionado= new Vector<String>();
        vectorAtributoSeleccionado=atributoSeleccionado;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanelLimpiarOut = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jButtonEliminarOut = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jTextFieldMaximoLimpiarOut = new javax.swing.JTextField();
        jTextFieldMinimoLimpiarOut = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle(":. Eliminar Outliers :.");

        jPanelLimpiarOut.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel1.setText("Limites");

        jButtonEliminarOut.setText("Eliminar");
        jButtonEliminarOut.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonEliminarOutActionPerformed(evt);
            }
        });

        jLabel2.setText("Minimo");

        jLabel3.setText("Maximo");

        jTextFieldMinimoLimpiarOut.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldMinimoLimpiarOutKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout jPanelLimpiarOutLayout = new javax.swing.GroupLayout(jPanelLimpiarOut);
        jPanelLimpiarOut.setLayout(jPanelLimpiarOutLayout);
        jPanelLimpiarOutLayout.setHorizontalGroup(
            jPanelLimpiarOutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelLimpiarOutLayout.createSequentialGroup()
                .addGroup(jPanelLimpiarOutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelLimpiarOutLayout.createSequentialGroup()
                        .addGap(28, 28, 28)
                        .addComponent(jLabel1))
                    .addGroup(jPanelLimpiarOutLayout.createSequentialGroup()
                        .addGap(51, 51, 51)
                        .addGroup(jPanelLimpiarOutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING))
                        .addGap(28, 28, 28)
                        .addGroup(jPanelLimpiarOutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jTextFieldMinimoLimpiarOut)
                            .addComponent(jTextFieldMaximoLimpiarOut, javax.swing.GroupLayout.DEFAULT_SIZE, 53, Short.MAX_VALUE)))
                    .addGroup(jPanelLimpiarOutLayout.createSequentialGroup()
                        .addGap(78, 78, 78)
                        .addComponent(jButtonEliminarOut)))
                .addContainerGap(65, Short.MAX_VALUE))
        );
        jPanelLimpiarOutLayout.setVerticalGroup(
            jPanelLimpiarOutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelLimpiarOutLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(28, 28, 28)
                .addGroup(jPanelLimpiarOutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jTextFieldMinimoLimpiarOut, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelLimpiarOutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldMaximoLimpiarOut, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 17, Short.MAX_VALUE)
                .addComponent(jButtonEliminarOut)
                .addGap(24, 24, 24))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanelLimpiarOut, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanelLimpiarOut, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonEliminarOutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonEliminarOutActionPerformed
        // TODO add your handling code here:
       minimo=0;
       maximo=0;
        if(jTextFieldMaximoLimpiarOut.getText().equals("") || jTextFieldMinimoLimpiarOut.getText().equals(""))
        {
            JOptionPane.showMessageDialog(null, "Ingrese los valores", "Campos vacios", JOptionPane.INFORMATION_MESSAGE);
        }
        else
        {
            minimo= Integer.parseInt(jTextFieldMinimoLimpiarOut.getText());
            maximo=Integer.parseInt(jTextFieldMaximoLimpiarOut.getText());
            System.out.print("Minimo Outliers: "+minimo);
            System.out.print("Maximo Outliers: "+maximo);
            if(minimo>=maximo)
            {
                JOptionPane.showMessageDialog(null, "Valor minimo debe ser menor que valor maximo", "Intervalo incorrecto", JOptionPane.ERROR_MESSAGE);
            }
            else
            {
               this.show(false);
               String nombreVista= nombreTabla;
               String atributoLimpiarOutliers="";
               Controladora objControladora= new Controladora();

               System.out.println("nombre Vista :"+ nombreVista);
               System.out.println("tamano Vector :"+ vectorAtributoSeleccionado.size());
               System.out.println("contenido Vector :"+ vectorAtributoSeleccionado.elementAt(0));
               atributoLimpiarOutliers=vectorAtributoSeleccionado.elementAt(0);
               //objControladora.eliminarOutliers(nombreVista, atributoLimpiarOutliers, vectorAtributosNoSeleccionados);
               objControladora.eliminarOutliers(nombreVista, atributoLimpiarOutliers,vectorTodosAtributos, minimo, maximo);
            }
            
        }        
    }//GEN-LAST:event_jButtonEliminarOutActionPerformed

    public int getValorMinimo()
    {
        System.out.print("Minimo: "+minimo);
        return minimo;
    }

    public int getValorMaximo()
    {
        System.out.print("Maximo: "+maximo);
        return maximo;
    }

    private void jTextFieldMinimoLimpiarOutKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldMinimoLimpiarOutKeyTyped
        // TODO add your handling code here:
        char caracter= evt.getKeyChar();
        if(((caracter<'0') || (caracter> '9')) && (caracter != evt.VK_BACK_SPACE))
        {
            evt.consume();
        }

    }//GEN-LAST:event_jTextFieldMinimoLimpiarOutKeyTyped

    /**
    * @param args the command line arguments
    */
//    public static void main(String args[]) {
//        java.awt.EventQueue.invokeLater(new Runnable() {
//            public void run() {
//                new LimpiarOutliersGUI().setVisible(true);
//            }
//        });
//    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonEliminarOut;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPanel jPanelLimpiarOut;
    private javax.swing.JTextField jTextFieldMaximoLimpiarOut;
    private javax.swing.JTextField jTextFieldMinimoLimpiarOut;
    // End of variables declaration//GEN-END:variables

}
